import QtQuick 2.7
import QtQuick.Window 2.2

Window {
    property variant textArray: [qsTr("Control Item"), qsTr("Rocket Item")];

    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    Rectangle {
        id: rectList;

        width: 150;
        color: "white";
        anchors.left: parent.left;
        anchors.top: parent.top;
        anchors.bottom: parent.bottom;

        Column {
            id: column;

            anchors.fill: parent;
            spacing: 1;

            DButton {
                id: btnCtrl;
                height: 40;
                width: column.width;
                text: textArray[0];
                checked: true;

                onClicked: {
                    buttonClicked(0);
                    btnCtrl.checked = true;
                    btnRocket.checked = false;
                }
            }

            DButton {
                id: btnRocket;
                height: 40;
                width: column.width;
                text: textArray[1];

                onClicked: {
                    buttonClicked(1);
                    btnCtrl.checked = false;
                    btnRocket.checked = true;
                }
            }
        }

        Rectangle {
            width: 1;
            color: "gray";
            anchors.top: parent.top;
            anchors.right: parent.right;
            anchors.bottom: parent.bottom;
        }
    }

    Rectangle {
        id: rectTitle;
        color: "white";
        height: 40;
        anchors.left: rectList.right;
        anchors.top: parent.top;
        anchors.right: parent.right;

        Text {
            id: textTitle;
            font.pointSize: 20;
            font.family: "Consolas";
            anchors.fill: parent;
            text: textArray[0];
            horizontalAlignment: Qt.AlignHCenter;
            verticalAlignment: Qt.AlignVCenter;
        }

        Rectangle {
            height: 1;
            color: "gray";
            anchors.left: parent.left;
            anchors.right: parent.right;
            anchors.bottom: parent.bottom;
        }
    }

    Rectangle {
        anchors.left: rectList.right;
        anchors.top: rectTitle.bottom;
        anchors.right: parent.right;
        anchors.bottom: parent.bottom;

        ControlItem {
            id: contrlItem;
            visible: true;
            anchors.fill: parent;

        }

        RocketItem {
            id: rockItem;
            visible: false;
            anchors.fill: parent;
        }

    }

    //判断按钮点击
    function buttonClicked(nIndex) {
        switch(nIndex)
        {
        case 0:
            contrlItem.visible = true;
            rockItem.visible = false;
            textTitle.text = textArray[0];
            break;
        case 1:
            contrlItem.visible = false;
            rockItem.visible = true;
            textTitle.text = textArray[1];
            break;
        default:
            break;
        }
    }


}
